'''
An example of a simple real Twisted application.

@author: Hatem Oraby
'''
from twisted.internet import reactor, protocol
import time
import sys

print "My Name is: " + str(__name__)


class Echo(protocol.Protocol):
    """This is just about the simplest possible protocol"""
    
    def dataReceived(self, data):
        "As soon as any data is received, write it back."
        print "Server Received: " + str(data)
        print "Server is writing data back"
        self.transport.write(data)



if __name__ == '__main__':
    factory = protocol.ServerFactory()
    factory.protocol = Echo
    reactor.listenTCP(8000,factory)
    reactor.run()